<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------
namespace addon\notice\logic;
use app\common\logic\LogicBase;
use \tpfcore\Core;

class Notice extends LogicBase
{
	public function getNotice($data=[]){
		return self::getList($data);
	}
	public function saveNotice($data=[]){
		$validate=Core::addonValidate($this->name);
        $validate_result = $validate->scene('add')->check($data);
        if (!$validate_result) {
            return [RESULT_ERROR, $validate->getError(), null];
        }
		$last_id=Core::loadAddonModel($this->name)->saveObject($data);
		if($last_id){
        	return [RESULT_SUCCESS, '操作成功', url("notice/Notice/index")];
        }else{
        	return [RESULT_ERROR, '操作失败', null];
        }
	}
	public function delNotice($data=[]){
		$result = self::deleteObject($data,true);
		if($result)
			return [RESULT_SUCCESS,"操作成功",url("notice/Notice/index")];
		return [RESULT_ERROR, '操作失败', null];
	}
}